package com.mohan.dlxj.service.impl;

import com.mohan.dlxj.common.JsonResult;
import com.mohan.dlxj.mapper.PoleMapper;
import com.mohan.dlxj.pojo.Circuit;
import com.mohan.dlxj.pojo.Pole;
import com.mohan.dlxj.pojo.RoleList;
import com.mohan.dlxj.service.PoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PoleServiceImpl implements PoleService {
  @Autowired
  private PoleMapper poleMapper;

  @Override
  public JsonResult getPoleList(long current, long limit) {

    JsonResult jsonResult = new JsonResult();
    jsonResult.setCode(0);
    jsonResult.setMsg("");

    current = limit * (current - 1);
    List<Pole> list = poleMapper.selectPolePage(current, limit);
    jsonResult.setCount(poleMapper.selectPoleAll());//总条数
    jsonResult.setData(list);
    return jsonResult;
  }

  @Override
  public Integer getPoleAll() {
    Integer all = poleMapper.selectPoleAll();
    return all;
  }

  @Override
  public Pole getPoleById(Integer id) {
    return poleMapper.getPoleById(id);
  }

  @Override
  public void updatePole(Pole pole) {
    poleMapper.updatePole(pole);
  }

  @Override
  public void deletePole(Integer id) {
    poleMapper.deletePole(id);
  }

  @Override
  public void savePole(Pole pole) {
    poleMapper.savePole(pole);
  }

  @Override
  public void updatePoleAll(Pole pole) {
    poleMapper.updatePoleAll(pole);
  }
}
